#ifndef VROUTE_PORT_DATA_LIST_HPP_3
#define VROUTE_PORT_DATA_LIST_HPP_3

#include "vroute_sys.hpp"
#include "vroute_stack.hpp"
#include "vroute_IFServerdef.hpp"

namespace vroute_stack
{
    typedef struct _portInfo
    {
        unsigned char mask:4;
        unsigned char statu:4;
        unsigned char rindex:4;
        unsigned char rmask:4;
        NodeAddr raddr;
        void* attr;
    }portInfo;

    class portListMgr
    {
    public:
        static portListMgr* getInstance();
        static void releaseInstance();

        int Init(SystemStartType type);     

        int setKV(unsigned char socketIndex, portItemKey key, const void* value);
        int getKV(unsigned char socketIndex, portItemKey key, void*& value);

        int getOutPutPort(unsigned char socketIndex, unsigned char& outIndex);
        int getOutPutPortAddr(const Node& nextaddr, unsigned char& outIndex);
        int getOutPutPortByInIndex(unsigned char inIndex, unsigned char& outIndex);

        int canclePort(int socketIndex);
    private:
        portListMgr();
        ~portListMgr();
    private:
        static portListMgr* _instance;
        vos_criticalSection m_cs_port;
        portInfo* m_port_list;
        unsigned char m_mask;
    };
}
#endif //VROUTE_PORT_DATA_LIST_HPP_3